﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ExIF35
{
    public partial class Form1 : Form
    {
        Boolean editLoad = false;
        public int returnSelection;
        public int count; 

        public String exposureNumber;
        public String exposureAperture;
        public String exposureSpeed;
        public String exposureDateTime;
        public String exposureDateTimeDigitized;
        public String exposureTitle;
        public String exposureDescription;
        public Exposure theExposure;
        public String exposureFocalLength;
        public String Photographer;
        public int exposureProgram;
        public int exposureOrientation;
        public int exposureFlash;
        public int exposureMeter;
        public int exposureLS;
        Exposure thisExposure; 

        public Form1(String photog, int count)
        {
            InitializeComponent();
            this.count = count;
            this.count++;
            Exposure.Text = count.ToString();
            txtPhotog.Text = photog;
            dateTime.Text = DateTime.Now.ToString("yyyy:MM:dd HH:mm:ss");
        }

        public Form1(Exposure thisExposure, int returnselect)
        {
            InitializeComponent();
            this.thisExposure = thisExposure;
            returnSelection = returnselect;
            editLoad = true;
            txtPhotog.Text = thisExposure.Photographer;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            exposureNumber = Exposure.Text;
            exposureAperture = aperture.Text;
            exposureSpeed = speed.Text;
            exposureDateTime = dateTime.Text;
            exposureDateTimeDigitized = dateTimeDigitized.Text;
            exposureTitle = title.Text;
            exposureDescription = richTextBox1.Text;
            exposureFocalLength = focalLength.Text;
            exposureProgram = drpProgram.SelectedIndex;
            exposureFlash = drpFlash.SelectedIndex;
            exposureMeter = drpMeter.SelectedIndex;
            exposureLS = drpLight.SelectedIndex;
            Photographer = txtPhotog.Text;

            if (editLoad == false)
            {
                theExposure = new Exposure(exposureNumber, exposureAperture, exposureSpeed, exposureDateTime, exposureDateTimeDigitized, exposureTitle, exposureDescription, Photographer, exposureFocalLength);
            }
            else
            {
                theExposure = thisExposure;
                thisExposure.updateBase(exposureNumber, exposureAperture, exposureSpeed, exposureDateTime, exposureDateTimeDigitized, exposureTitle, exposureDescription, Photographer, exposureFocalLength);
            }

            theExposure.addExtended(exposureProgram, exposureOrientation, exposureFlash, exposureMeter, exposureLS);
            
            this.Close();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            if (editLoad == false)
            {
                Exposure.Text = count.ToString();
                drpProgram.SelectedIndex = 0;
                drpOrient.SelectedIndex = 0;
                drpFlash.SelectedIndex = 0;
                drpMeter.SelectedIndex = 2;
                drpLight.SelectedIndex = 0;
            }
            else
            {
                drpProgram.SelectedIndex = thisExposure.Program;
                drpOrient.SelectedIndex = thisExposure.Orientation;
                drpFlash.SelectedIndex = thisExposure.Flash;
                drpMeter.SelectedIndex = thisExposure.Meter;
                drpLight.SelectedIndex = thisExposure.LightSource;

                Exposure.Text = thisExposure.Number;
                aperture.Text = thisExposure.Aperture;
                speed.Text = thisExposure.Speed;
                dateTime.Text = thisExposure.Date;
                dateTimeDigitized.Text = thisExposure.DateDigitized;
                title.Text = thisExposure.Title;
                richTextBox1.Text = thisExposure.Description;
                focalLength.Text = thisExposure.FocalLength;

                button1.Text = "Save";
            }
        }

        private void dateTimeDigitized_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtPhotog_TextChanged(object sender, EventArgs e)
        {

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void drpLight_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
